<!--
 * @Author: lmk
 * @Date: 2022-04-17 11:25:57
 * @LastEditTime: 2022-07-01 11:34:53
 * @LastEditors: lmk
 * @Description: 
-->
<!--
 * @Author: lmk
 * @Date: 2022-04-15 22:27:06
 * @LastEditTime: 2022-04-16 22:58:45
 * @LastEditors: lmk
 * @Description: 
-->
<template>
  <pageView pageName="activityDetail" :isShowSearch="false" class="detailpage"  bannerImage="/img/banner/activitybanner.png">
    <div v-if="state.info">
      <div class="flex info">
        <div class="flex-1 flex items-center bg-white">
          <img :src="state.info.activitiFiguerImage" alt="" class="activitiFiguerImage">
        </div>
        <div class="content flex-1">
          <div class="name">{{isZh ? state.info.activityName : state.info.activityNameEnglish}}</div>
          <img src="/img/activity/a-line.png" alt="">
          <div class="desc" v-html="isZh ? state.info.activityDesc : state.info.activityDescEnglish"></div>
        </div>
      </div>
      <div class="tab-list flex">
        <div v-for="(item,index) in state.info.actorList " :key="index" 
          class="flex-1 tab" 
          :class="{active:state.activeIndex===index}"
          @click="setChange(index)">
          {{isZh ? item.actorJob : item.actorJobEnglish}}
        </div>
      </div>
    </div>
  </pageView>
  <div class="hide-pc flex mobile-img-box"  v-if="state.info&&state.info.actorList&&state.info.actorList.length">
    <div v-for="(item,index) in state.info.actorList " :key="index"  class="relative flex-1">
      <img :src="item.actorPhoto" alt="" class="slide-image">
      <div class="members-tag absolute flex items-center"  :class="{active:state.activeIndex===index}">
        <div>
          <p >{{isZh ? item.actorJob+'/' : ''}}{{isZh ?item.actorName : item.actorNameEnglish}}</p>
          <p>{{item.actorJobEnglish}}</p>
        </div>
      </div>
    </div>
  </div>
  <div class="flex hide-mobile" v-if="state.info&&state.info.actorList&&state.info.actorList.length">
    <div class="prev">
      <img src="/img/home/left.png" alt="">
    </div>
    <div class="center-content">
      <swiper :navigation="{
        nextEl:'.next',
        prevEl: '.prev'
      }" :modules="modules"
      @swiper="setSwiperRef"
      @slideChange="onSlideChange"
      :slides-per-view="4">
        <swiper-slide v-for="(item,index) in state.info.actorList " :key="index">
          <div class="relative">
            <img :src="item.actorPhoto" alt="" class="slide-image">
            <div class="members-tag absolute flex items-center"  :class="{active:state.activeIndex===index}">
              <div>
                <p>{{isZh ? item.actorJob+'/' : ''}}{{isZh ?item.actorName : item.actorNameEnglish}}</p>
                <p>{{item.actorJobEnglish}}</p>
              </div>
            </div>
          </div>
        </swiper-slide>
      </swiper>
    </div>
    <div class="next">
      <img src="/img/home/right.png" alt="">
    </div>
  </div>
</template>

<script>
import pageView from '@/components/pageView'
import { Navigation } from 'swiper';
import { Swiper, SwiperSlide } from "swiper/vue/swiper-vue";
import { useIsZh } from '@/utils/useIsZh';
import {  reactive } from 'vue';
import { useRoute } from 'vue-router';
import { getActivityVo } from '@/api/api';
export default {
  setup(){
    const {params} = useRoute()
    const {isZh} = useIsZh()
    const onSlideChange = (swiper) => {
      console.log(swiper.activeIndex)
    }
    let swiperRef = null;

    const setSwiperRef = (swiper) => {
      swiperRef = swiper;
    };
    const state = reactive({
      activeIndex: 0,
      info: '',
    })
    // 获取详细数据
    if(params.id){
      getActivityVo({activityId:params.id}).then(res=>{
        state.info = res;
      })
    }
    const setChange = (index)=>{
      state.activeIndex = index;
      if(index>0){
        const slideTo = index - 3;
        swiperRef.slideTo(slideTo, 0);
      }
    }
    return {
      onSlideChange,
      modules:[Navigation],
      isZh,
      state,
      setChange,
      setSwiperRef,
      
    };
  },
  components: {
    pageView,
    Swiper, 
    SwiperSlide
  }
}
</script>

<style lang="scss" scoped>
@media screen and (min-width: 1400px) {
  .content{
    background-color: #fff;
    .activitiFiguerImage{
      width: 100%;
      height: calc((100vw - 160px) / 2 * 0.55);
      object-fit: cover;
    }
    .name{
      padding-left: 80px;
      font-size: 24px;
      font-weight: bold;
      color: #202020;
      margin: 48px 0 30px;
    }
    .desc{
      padding-left: 80px;
      margin-top: 20px;
      font-size: 14px;
      font-weight: 400;
      color: #666666;
      line-height: 30px;
      padding-right: 86px;
      min-height: 150px;
    }
  }
  .tab{
    background: white;
    font-size: 24px;
    color: #666666;
    height: 80px;
    text-align: center;
    line-height: 80px;
    position: relative;
    cursor: pointer;
    &.active{
      background: $activeTxt;
      color: #FFFFFF;
    }
    &:not(:last-child){
      &::after{
        content: "";
        position: absolute;
        height: 60px;
        width: 1px;
        right: 0;
        top: 10px;
        background: linear-gradient(180deg, rgba(212, 178, 104, 0) 0%, #D4B268 53%, rgba(212, 178, 104, 0) 100%);
      }
    }
  }
  .center-content{
    width: calc(100vw - 160px);
  }
  .prev,.next{
    width: 80px;
    background: $activeTxt;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    &.swiper-button-disabled{
      background: transparent;
    }
    img{
      height: 20px;
    }
  }
  .slide-image{
    width: 100%;
    object-fit: cover;
    height: calc((100vw - 160px) / 4);
  }
  .members-tag{
    bottom: 0;
    left: 0;
    right: 0;
    height: 80px;
    background: $activeTxt;
    color: white;
    font-size: 20px;
    padding-left: 42px;
    transform: translateY(100%);
    transition: all 0.3s;
    &.active{
      transform: translateY(0);
    }
  }
}
@media screen and (max-width: 1401px) {
  .info{
    display: block;
  }
  .content{
    background-color: #fff;
    .activitiFiguerImage{
      width: 100%;
      height: calc((100vw - 30px) * 0.9);
      object-fit: cover;
    }
    .name{
      padding: 15px;
      font-size: 12px;
      font-weight: bold;
      color: #202020;
    }
    .desc{
      padding: 15px;
      font-size: 7px;
      font-weight: 400;
      color: #666666;
      line-height: 15px;
    }
  }
  .tab{
    background: white;
    font-size: 12px;
    color: #666666;
    height: 40px;
    text-align: center;
    line-height: 40px;
    position: relative;
    cursor: pointer;
    width: calc((100vw - 30px) / 2);
    flex: none;
    &-list{
      flex-wrap: wrap;
    }
    &.active{
      background: $activeTxt;
      color: #FFFFFF;
    }
    &:not(:last-child){
      &::after{
        content: "";
        position: absolute;
        height: 30px;
        width: 1px;
        right: 0;
        top: 5px;
        background: linear-gradient(180deg, rgba(212, 178, 104, 0) 0%, #D4B268 53%, rgba(212, 178, 104, 0) 100%);
      }
    }
  }
  .center-content{
    width: calc(100vw - 160px);
  }
  .prev,.next{
    width: 80px;
    background: $activeTxt;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    &.swiper-button-disabled{
      background: transparent;
    }
    img{
      height: 20px;
    }
  }
  .slide-image{
    width: 100%;
    height: calc((100vw - 30px) / 2);
    object-fit: cover;
  }
  .members-tag{
    bottom: 0;
    left: 0;
    right: 0;
    height: 40px;
    background: $activeTxt;
    color: white;
    font-size: 10px;
    padding-left: 22px;
    transform: translateY(100%);
    transition: all 0.3s;
    &.active{
      transform: translateY(0);
    }
  }
  .mobile-img-box{
    padding: 0 15px;
    .relative{
      overflow: hidden;
    }
  }
}
</style>
<style lang="scss">

.detailpage{
  .page-content{
    padding-bottom: 0;
  }
}
</style>